<?php

namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;

class UploadController extends BaseController
{
    /**
     * 上传文件/图片
     */
    public function uploadFile(Request $request)
    {
        // 自定义上传类型,及路径
        $type_arr = [
            1 => 'files',
            2 => 'images',
        ];
        $file = $request->file('file');
        $type = $request->input('type');
        if (!$type || !isset($type_arr[$type])) return result_json(400, '参数错误');
        $save = upload_img($file, $type_arr[$type]);
        return $save;
    }

}